﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharedContent;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GlobalGameJam
{
    class Button : Plateform
    {
        private bool shuffled;
        private string _type;
        private float _timer;
        Sprite otherSprite;
        public void setType(string type)
        {
            this._type = type;
        }
        public void addText(Texture2D text)
        {
            otherSprite= new Sprite();
            otherSprite.sprite = text;
            otherSprite.rec = new Rectangle(0, 0, text.Width, text.Height);
            otherSprite.data = new Color[text.Width * text.Height];
            text.GetData(otherSprite.data);
        }
        public Button(GameplayScreen gs) : base(gs)
        {
            shuffled = false;
            _timer = 0;
        }
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            _timer += gameTime.ElapsedGameTime.Milliseconds;
            if (shuffled && _timer > 5000)
            {
                shuffled = false;
                _timer = 0;
                this._game.player.inputManager.reset();
            }
        }
        public override bool collide()
        {
            if (_game.player.sprite.getState() == SpriteManager.State.BiteLeft ||
                _game.player.sprite.getState() == SpriteManager.State.BiteRight)
            if (_type == "nerf")
            {
                if (sprite != otherSprite.sprite)
                {
                    sprite = otherSprite.sprite;
                    data = otherSprite.data;
                    _game.notifyEvent("nerf");
                }
            }
            else if (_type == "changeKeys")
            {
                if (!shuffled)
                    _game.player.inputManager.shuffle();
                shuffled = true;
                _game.notifyEvent("changeKeys");
            }
            return false;
        }
    }
}
